<meta charset="UTF-8">
<div >
	<h3>教师管理<small>Teacher</small></h3>
	<hr>
	<div>
		<table id="mytable">
			<thead>
				<tr>
					<th data-checkbox="true"></th>
					<th data-field="username">用户名</th>
					<th data-field="name">教师名称</th>
				</tr>
			</thead>
		</table>
	</div>
	<script type="text/javascript">
	$(function(){
		$('#mytable').datagrid({
			path:'teacher',
			buttons:[$.fn.datagrid.toolbar.buttons.add,$.fn.datagrid.toolbar.buttons.edit,$.fn.datagrid.toolbar.buttons.remove,$.fn.datagrid.toolbar.buttons.search,
				$.createBtn({
					iconCls:'glyphicon glyphicon-repeat',
					text:'重置密码',
					handler:function(){
						var row=$('#mytable').bootstrapTable('getSelections');
						if(row.length){
							id=row[0].id;
						}else{
							bootbox.alert('请选择一行再进行此操作');
							return;
						}
						bootbox.confirm({
							message:'是否重置密码！',
							callback:function (value){
								if(value){
									 $.post('teacher/reset', {id:id}, function(result){
										 if(result.success){
											}else{
												bootbox.alert(result.msg);
											}
									 })
								}
							},
							buttons:{
								confirm:{
									confirm:'确认',
									className:'btn-primary'
								},
								cancel:{
									confirm:'取消',
									className:'btn-default'
								}
							}
						})
					}
				})
			]
		})
	})
	</script>
</div>